package com.cs307.redcross.client;

import java.io.Serializable;
import java.util.Date;
import java.util.Vector;

import com.google.gwt.user.client.Window;
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.google.gwt.user.client.ui.DialogBox;
import com.google.gwt.user.client.ui.PopupPanel;
import com.google.gwt.user.client.ui.AbsolutePanel;
import com.google.gwt.user.client.ui.ListBox;
import com.google.gwt.user.client.ui.Button;
import com.google.gwt.user.client.ui.Label;
import com.google.gwt.user.client.ui.CheckBox;
import com.google.gwt.user.client.ui.RadioButton;
import com.google.gwt.user.client.ui.TextArea;
import com.google.gwt.core.client.GWT;
import com.google.gwt.event.logical.shared.ValueChangeHandler;
import com.google.gwt.event.logical.shared.ValueChangeEvent;
import com.google.gwt.event.dom.client.ChangeHandler;
import com.google.gwt.event.dom.client.ChangeEvent;
import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.event.dom.client.ClickHandler;
import com.google.gwt.i18n.client.DateTimeFormat;
import com.google.gwt.user.client.ui.TextBox;
import com.google.gwt.user.client.ui.Anchor;
import com.google.gwt.user.datepicker.client.DatePicker;

public class AddReminderPopupPanel extends DialogBox implements Serializable {
	private static final long serialVersionUID = -5573026417636275425L;
	private String relogString = "If this problem persists try relogging into the system.";
	private DatabaseHandlerServiceAsync databaseHandlerService = (DatabaseHandlerServiceAsync) GWT.create(DatabaseHandlerService.class);
	
	Vector<ReminderTemplate> reminderTemplateVector = new Vector<ReminderTemplate>();
	
	Group selectedViewGroup;
	Group selectedAddGroup;
	Date newSendDate;
	Date eventDate;
	
	ListBox viewGroupsListbox;
	ListBox addedGroupsListbox;
	Button addButton;
	Button removeButton;
	Button addReminderButton;
	Button cancelButton;
	TextArea messageTextArea;
	ListBox templateCombobox;
	CheckBox useTemplateCheckbox;
	PopupPanel startDatePopup;
	DatePicker startDatePicker;
	TextBox sendDateTextBox;
	Anchor sendDateAnchor;
	ListBox deliveryMethodCombobox;
	Label lblSendTime;
	ListBox sendTimeHourCombobox;
	ListBox sendTimeMinuteCombobox;
	ListBox sendTimeAMPMCombobox;
	Label lblSendDate;
	Label lblSendMethod;
	RadioButton specifyRelativeCheckbox;
	Label label;
	ListBox daysBeforeCombobox;
	Label label_1;
	ListBox hoursBeforeCombobox;
	ListBox minutesBeforeCombobox;
	Label label_2;
	RadioButton specifyAbsoluteCheckbox;
	
	public AddReminderPopupPanel() {
	}
	
	/**
	 * @wbp.parser.constructor
	 */
	public AddReminderPopupPanel(Date d) {
		this.eventDate = d;
		this.setText("Add Reminder");
		this.setGlassEnabled(true);
		
		databaseHandlerService.getAllReminderTemplates(new AsyncCallback<Vector<ReminderTemplate>>() {
			
			@Override
			public void onSuccess(Vector<ReminderTemplate> result) {
				if (result != null && !result.isEmpty()) {
					reminderTemplateVector = new Vector<ReminderTemplate>(result);
					for (ReminderTemplate rt : reminderTemplateVector) {
						if (rt == null)
							continue;
						
						templateCombobox.addItem(rt.getName());
					}
				}
			}
			
			@Override
			public void onFailure(Throwable caught) {
				Window.alert("Error: Failed to contact server. " + relogString);
			}
		});
		
		setSize("592px", "419px");
		
		AbsolutePanel absolutePanel = new AbsolutePanel();
		setWidget(absolutePanel);
		absolutePanel.setSize("599px", "591px");
		
		addReminderButton = new Button("Add Reminder");
		absolutePanel.add(addReminderButton, 307, 553);
		addReminderButton.setSize("138px", "28px");
		
		cancelButton = new Button("Cancel");
		absolutePanel.add(cancelButton, 451, 553);
		cancelButton.setSize("138px", "28px");
		
		useTemplateCheckbox = new CheckBox("Create Reminder from Template");
		useTemplateCheckbox.addValueChangeHandler(new ValueChangeHandler<Boolean>() {
			@SuppressWarnings("deprecation")
			public void onValueChange(ValueChangeEvent<Boolean> event) {
				if (useTemplateCheckbox.getValue()) {
					templateCombobox.setEnabled(true);
					specifyRelativeCheckbox.setValue(true);
					daysBeforeCombobox.setEnabled(true);
					hoursBeforeCombobox.setEnabled(true);
					minutesBeforeCombobox.setEnabled(true);
					
					specifyAbsoluteCheckbox.setValue(false);
					sendTimeAMPMCombobox.setEnabled(false);
					sendTimeHourCombobox.setEnabled(false);
					sendTimeMinuteCombobox.setEnabled(false);
					sendDateAnchor.setEnabled(false);
					sendDateTextBox.setEnabled(false);
					
					if (templateCombobox.getSelectedIndex() != -1) {
						if (reminderTemplateVector.get(templateCombobox.getSelectedIndex()) != null) {
							ReminderTemplate selected = reminderTemplateVector.get(templateCombobox.getSelectedIndex());
							messageTextArea.setText(selected.getMessage());
							daysBeforeCombobox.setSelectedIndex(selected.getDaysBeforeEvent());
							hoursBeforeCombobox.setSelectedIndex(selected.getHoursBeforeEvent());
							minutesBeforeCombobox.setSelectedIndex(selected.getMinutesBeforeEvent());
							
							Date absoluteDate = selected.getTimeOfReminderFromTemplate(eventDate);
							if (absoluteDate.getHours() == 0) {
								sendTimeHourCombobox.setItemSelected(11, true);
								sendTimeAMPMCombobox.setItemSelected(0, true);
							}
							else if (absoluteDate.getHours() < 12) {
								sendTimeHourCombobox.setItemSelected(absoluteDate.getHours() - 1, true);
								sendTimeAMPMCombobox.setItemSelected(0, true);
							}
							else if (absoluteDate.getHours() == 12) {
								sendTimeHourCombobox.setItemSelected(11, true);
								sendTimeAMPMCombobox.setItemSelected(1, true);
							}
							else if (absoluteDate.getHours() > 12) {
								sendTimeHourCombobox.setItemSelected(absoluteDate.getHours() - 13, true);
								sendTimeAMPMCombobox.setItemSelected(1, true);
							}
							sendDateTextBox.setText(DateTimeFormat.getFormat("MM/dd/yy").format(absoluteDate));
							
							if (selected.email && selected.SMS) {
								deliveryMethodCombobox.setItemSelected(0, true);
							}
							else if (selected.email && !selected.SMS) {
								deliveryMethodCombobox.setItemSelected(1, true);
							}
							else {
								deliveryMethodCombobox.setItemSelected(2, true);
							}
						}
					}
				}
				else {
					templateCombobox.setEnabled(false);
					messageTextArea.setEnabled(true);
					
					specifyRelativeCheckbox.setEnabled(true);
					daysBeforeCombobox.setEnabled(true);
					hoursBeforeCombobox.setEnabled(true);
					minutesBeforeCombobox.setEnabled(true);
					
					specifyAbsoluteCheckbox.setValue(false);
					sendTimeAMPMCombobox.setEnabled(false);
					sendTimeHourCombobox.setEnabled(false);
					sendTimeMinuteCombobox.setEnabled(false);
					sendDateAnchor.setEnabled(false);
					sendDateTextBox.setEnabled(false);
					sendDateTextBox.setText("");
				}
			}
		});
		absolutePanel.add(useTemplateCheckbox, 10, 10);
		
		templateCombobox = new ListBox();
		templateCombobox.addChangeHandler(new ChangeHandler() {
			@SuppressWarnings("deprecation")
			public void onChange(ChangeEvent event) {
				if (templateCombobox.getSelectedIndex() != -1) {
					if (reminderTemplateVector.get(templateCombobox.getSelectedIndex()) != null) {
						ReminderTemplate selected = reminderTemplateVector.get(templateCombobox.getSelectedIndex());
						messageTextArea.setText(selected.getMessage());
						daysBeforeCombobox.setSelectedIndex(selected.getDaysBeforeEvent());
						hoursBeforeCombobox.setSelectedIndex(selected.getHoursBeforeEvent());
						minutesBeforeCombobox.setSelectedIndex(selected.getMinutesBeforeEvent());
						
						Date absoluteDate = selected.getTimeOfReminderFromTemplate(eventDate);
						if (absoluteDate.getHours() == 0) {
							sendTimeHourCombobox.setItemSelected(11, true);
							sendTimeAMPMCombobox.setItemSelected(0, true);
						}
						else if (absoluteDate.getHours() < 12) {
							sendTimeHourCombobox.setItemSelected(absoluteDate.getHours() - 1, true);
							sendTimeAMPMCombobox.setItemSelected(0, true);
						}
						else if (absoluteDate.getHours() == 12) {
							sendTimeHourCombobox.setItemSelected(11, true);
							sendTimeAMPMCombobox.setItemSelected(1, true);
						}
						else if (absoluteDate.getHours() > 12) {
							sendTimeHourCombobox.setItemSelected(absoluteDate.getHours() - 13, true);
							sendTimeAMPMCombobox.setItemSelected(1, true);
						}
						sendDateTextBox.setText(DateTimeFormat.getFormat("MM/dd/yy").format(absoluteDate));
						
						if (selected.email && selected.SMS) {
							deliveryMethodCombobox.setItemSelected(0, true);
						}
						else if (selected.email && !selected.SMS) {
							deliveryMethodCombobox.setItemSelected(1, true);
						}
						else {
							deliveryMethodCombobox.setItemSelected(2, true);
						}
					}
				}
				else {
					templateCombobox.setEnabled(false);
					messageTextArea.setEnabled(true);
					
					specifyRelativeCheckbox.setEnabled(true);
					daysBeforeCombobox.setEnabled(true);
					hoursBeforeCombobox.setEnabled(true);
					minutesBeforeCombobox.setEnabled(true);
					
					specifyAbsoluteCheckbox.setValue(false);
					sendTimeAMPMCombobox.setEnabled(false);
					sendTimeHourCombobox.setEnabled(false);
					sendTimeMinuteCombobox.setEnabled(false);
					sendDateAnchor.setEnabled(false);
					sendDateTextBox.setEnabled(false);
					sendDateTextBox.setText("");
				}
			}
		});
		absolutePanel.add(templateCombobox, 221, 10);
		templateCombobox.setSize("361px", "24px");
		
		Label lblReminderMessage = new Label("Reminder Message:");
		absolutePanel.add(lblReminderMessage, 10, 56);
		
		messageTextArea = new TextArea();
		absolutePanel.add(messageTextArea, 10, 80);
		messageTextArea.setSize("572px", "255px");
		
		templateCombobox.setEnabled(false);
		
		lblSendTime = new Label("Send Time:");
		absolutePanel.add(lblSendTime, 10, 479);
		lblSendTime.setSize("149px", "18px");
		
		sendTimeHourCombobox = new ListBox();
		sendTimeHourCombobox.addItem("1");
		sendTimeHourCombobox.addItem("2");
		sendTimeHourCombobox.addItem("3");
		sendTimeHourCombobox.addItem("4");
		sendTimeHourCombobox.addItem("5");
		sendTimeHourCombobox.addItem("6");
		sendTimeHourCombobox.addItem("7");
		sendTimeHourCombobox.addItem("8");
		sendTimeHourCombobox.addItem("9");
		sendTimeHourCombobox.addItem("10");
		sendTimeHourCombobox.addItem("11");
		sendTimeHourCombobox.addItem("12");
		sendTimeHourCombobox.setEnabled(false);
		absolutePanel.add(sendTimeHourCombobox, 10, 503);
		sendTimeHourCombobox.setSize("50px", "24px");
		
		sendTimeMinuteCombobox = new ListBox();
		sendTimeMinuteCombobox.addItem("00");
		sendTimeMinuteCombobox.addItem("01");
		sendTimeMinuteCombobox.addItem("02");
		sendTimeMinuteCombobox.addItem("03");
		sendTimeMinuteCombobox.addItem("04");
		sendTimeMinuteCombobox.addItem("05");
		sendTimeMinuteCombobox.addItem("06");
		sendTimeMinuteCombobox.addItem("07");
		sendTimeMinuteCombobox.addItem("08");
		sendTimeMinuteCombobox.addItem("09");
		sendTimeMinuteCombobox.addItem("10");
		sendTimeMinuteCombobox.addItem("11");
		sendTimeMinuteCombobox.addItem("12");
		sendTimeMinuteCombobox.addItem("13");
		sendTimeMinuteCombobox.addItem("14");
		sendTimeMinuteCombobox.addItem("15");
		sendTimeMinuteCombobox.addItem("16");
		sendTimeMinuteCombobox.addItem("17");
		sendTimeMinuteCombobox.addItem("18");
		sendTimeMinuteCombobox.addItem("19");
		sendTimeMinuteCombobox.addItem("20");
		sendTimeMinuteCombobox.addItem("21");
		sendTimeMinuteCombobox.addItem("22");
		sendTimeMinuteCombobox.addItem("23");
		sendTimeMinuteCombobox.addItem("24");
		sendTimeMinuteCombobox.addItem("25");
		sendTimeMinuteCombobox.addItem("26");
		sendTimeMinuteCombobox.addItem("27");
		sendTimeMinuteCombobox.addItem("28");
		sendTimeMinuteCombobox.addItem("29");
		sendTimeMinuteCombobox.addItem("30");
		sendTimeMinuteCombobox.addItem("31");
		sendTimeMinuteCombobox.addItem("32");
		sendTimeMinuteCombobox.addItem("33");
		sendTimeMinuteCombobox.addItem("34");
		sendTimeMinuteCombobox.addItem("35");
		sendTimeMinuteCombobox.addItem("36");
		sendTimeMinuteCombobox.addItem("37");
		sendTimeMinuteCombobox.addItem("38");
		sendTimeMinuteCombobox.addItem("39");
		sendTimeMinuteCombobox.addItem("40");
		sendTimeMinuteCombobox.addItem("41");
		sendTimeMinuteCombobox.addItem("42");
		sendTimeMinuteCombobox.addItem("43");
		sendTimeMinuteCombobox.addItem("44");
		sendTimeMinuteCombobox.addItem("45");
		sendTimeMinuteCombobox.addItem("46");
		sendTimeMinuteCombobox.addItem("47");
		sendTimeMinuteCombobox.addItem("48");
		sendTimeMinuteCombobox.addItem("49");
		sendTimeMinuteCombobox.addItem("50");
		sendTimeMinuteCombobox.addItem("51");
		sendTimeMinuteCombobox.addItem("52");
		sendTimeMinuteCombobox.addItem("53");
		sendTimeMinuteCombobox.addItem("54");
		sendTimeMinuteCombobox.addItem("55");
		sendTimeMinuteCombobox.addItem("56");
		sendTimeMinuteCombobox.addItem("57");
		sendTimeMinuteCombobox.addItem("58");
		sendTimeMinuteCombobox.addItem("59");
		sendTimeMinuteCombobox.setEnabled(false);
		absolutePanel.add(sendTimeMinuteCombobox, 65, 503);
		sendTimeMinuteCombobox.setSize("50px", "18px");
		
		sendTimeAMPMCombobox = new ListBox();
		sendTimeAMPMCombobox.addItem("AM");
		sendTimeAMPMCombobox.addItem("PM");
		sendTimeAMPMCombobox.setEnabled(false);
		absolutePanel.add(sendTimeAMPMCombobox, 133, 503);
		sendTimeAMPMCombobox.setSize("53px", "18px");
		
		lblSendDate = new Label("Send Date:");
		absolutePanel.add(lblSendDate, 233, 479);
		lblSendDate.setSize("74px", "18px");
		
		sendDateTextBox = new TextBox();
		sendDateTextBox.setEnabled(false);
		absolutePanel.add(sendDateTextBox, 233, 503);
		sendDateTextBox.setSize("141px", "13px");
		
		sendDateAnchor = new Anchor();
		sendDateAnchor.setText("Calendar");
		absolutePanel.add(sendDateAnchor, 331, 479);
		sendDateAnchor.setSize("51px", "18px");
		
		sendDateAnchor.addClickHandler(new ClickHandler(){
			
			@Override
			public void onClick(ClickEvent event){
				startDatePopup.setPopupPosition(sendDateAnchor.getAbsoluteLeft(), sendDateAnchor.getAbsoluteTop());
				startDatePopup.show();
			}
		});
		sendDateAnchor.setText("Calendar");
		absolutePanel.add(sendDateAnchor, 331, 479);
		sendDateAnchor.setSize("51px", "18px");
		
		startDatePopup = new PopupPanel(true);
		startDatePicker = new DatePicker();
		
		startDatePopup.add(startDatePicker);
		
		startDatePicker.addValueChangeHandler(new ValueChangeHandler<Date>() {
			
			@Override
			public void onValueChange(ValueChangeEvent<Date> event) {
		        newSendDate = event.getValue();
		        String dateString = DateTimeFormat.getFormat("MM/dd/yy").format(newSendDate);
		        sendDateTextBox.setText(dateString);
		        		        
		        startDatePopup.hide();
			}
		});
		
		sendDateTextBox.setEnabled(false);
		
		lblSendMethod = new Label("Delivery method:");
		absolutePanel.add(lblSendMethod, 440, 479);
		lblSendMethod.setSize("149px", "18px");
		
		deliveryMethodCombobox = new ListBox();
		deliveryMethodCombobox.addItem("Text + Email");
		deliveryMethodCombobox.addItem("Email Only");
		deliveryMethodCombobox.addItem("Text Only");
		deliveryMethodCombobox.setEnabled(false);
		absolutePanel.add(deliveryMethodCombobox, 440, 503);
		deliveryMethodCombobox.setSize("149px", "24px");
		
		sendTimeAMPMCombobox.setEnabled(true);
		sendTimeHourCombobox.setEnabled(true);
		sendTimeMinuteCombobox.setEnabled(true);
		deliveryMethodCombobox.setEnabled(true);
		
		specifyRelativeCheckbox = new RadioButton("time", "Specify Relative Time Before Event:");
		specifyRelativeCheckbox.addValueChangeHandler(new ValueChangeHandler<Boolean>() {
			public void onValueChange(ValueChangeEvent<Boolean> event) {
				if (specifyRelativeCheckbox.getValue()) {
					daysBeforeCombobox.setEnabled(true);
					hoursBeforeCombobox.setEnabled(true);
					minutesBeforeCombobox.setEnabled(true);
					
					sendDateAnchor.setEnabled(false);
					sendTimeAMPMCombobox.setEnabled(false);
					sendTimeHourCombobox.setEnabled(false);
					sendTimeMinuteCombobox.setEnabled(false);
				}
			}
		});
		absolutePanel.add(specifyRelativeCheckbox, 10, 383);
		specifyRelativeCheckbox.setSize("251px", "19px");
		
		label = new Label("days,");
		absolutePanel.add(label, 66, 408);
		label.setSize("32px", "18px");
		
		daysBeforeCombobox = new ListBox();
		daysBeforeCombobox.addChangeHandler(new ChangeHandler() {
			public void onChange(ChangeEvent event) {
			}
		});
		daysBeforeCombobox.addItem("0");
		daysBeforeCombobox.addItem("1");
		daysBeforeCombobox.addItem("2");
		daysBeforeCombobox.addItem("3");
		daysBeforeCombobox.addItem("4");
		daysBeforeCombobox.addItem("5");
		daysBeforeCombobox.addItem("6");
		daysBeforeCombobox.addItem("7");
		daysBeforeCombobox.addItem("8");
		daysBeforeCombobox.addItem("9");
		daysBeforeCombobox.addItem("10");
		daysBeforeCombobox.addItem("11");
		daysBeforeCombobox.addItem("12");
		daysBeforeCombobox.addItem("13");
		daysBeforeCombobox.addItem("14");
		daysBeforeCombobox.addItem("15");
		daysBeforeCombobox.addItem("16");
		daysBeforeCombobox.addItem("17");
		daysBeforeCombobox.addItem("18");
		daysBeforeCombobox.addItem("19");
		daysBeforeCombobox.addItem("20");
		daysBeforeCombobox.addItem("21");
		daysBeforeCombobox.addItem("22");
		daysBeforeCombobox.addItem("23");
		daysBeforeCombobox.addItem("24");
		daysBeforeCombobox.addItem("25");
		daysBeforeCombobox.addItem("26");
		daysBeforeCombobox.addItem("27");
		daysBeforeCombobox.addItem("28");
		daysBeforeCombobox.addItem("29");
		daysBeforeCombobox.addItem("30");
		daysBeforeCombobox.addItem("31");
		daysBeforeCombobox.addItem("32");
		daysBeforeCombobox.addItem("33");
		daysBeforeCombobox.addItem("34");
		daysBeforeCombobox.addItem("35");
		daysBeforeCombobox.addItem("36");
		daysBeforeCombobox.addItem("37");
		daysBeforeCombobox.addItem("38");
		daysBeforeCombobox.addItem("39");
		daysBeforeCombobox.addItem("40");
		daysBeforeCombobox.addItem("41");
		daysBeforeCombobox.addItem("42");
		daysBeforeCombobox.addItem("43");
		daysBeforeCombobox.addItem("44");
		daysBeforeCombobox.addItem("45");
		daysBeforeCombobox.addItem("46");
		daysBeforeCombobox.addItem("47");
		daysBeforeCombobox.addItem("48");
		daysBeforeCombobox.addItem("49");
		daysBeforeCombobox.addItem("50");
		daysBeforeCombobox.addItem("51");
		daysBeforeCombobox.addItem("52");
		daysBeforeCombobox.addItem("53");
		daysBeforeCombobox.addItem("54");
		daysBeforeCombobox.addItem("55");
		daysBeforeCombobox.addItem("56");
		daysBeforeCombobox.addItem("57");
		daysBeforeCombobox.addItem("58");
		daysBeforeCombobox.addItem("59");
		daysBeforeCombobox.addItem("60");
		daysBeforeCombobox.addItem("61");
		daysBeforeCombobox.addItem("62");
		daysBeforeCombobox.setEnabled(false);
		absolutePanel.add(daysBeforeCombobox, 10, 408);
		daysBeforeCombobox.setSize("50px", "18px");
		
		label_1 = new Label("hours, and");
		absolutePanel.add(label_1, 163, 408);
		label_1.setSize("65px", "18px");
		
		hoursBeforeCombobox = new ListBox();
		hoursBeforeCombobox.addItem("0");
		hoursBeforeCombobox.addItem("1");
		hoursBeforeCombobox.addItem("2");
		hoursBeforeCombobox.addItem("3");
		hoursBeforeCombobox.addItem("4");
		hoursBeforeCombobox.addItem("5");
		hoursBeforeCombobox.addItem("6");
		hoursBeforeCombobox.addItem("7");
		hoursBeforeCombobox.addItem("8");
		hoursBeforeCombobox.addItem("9");
		hoursBeforeCombobox.addItem("10");
		hoursBeforeCombobox.addItem("11");
		hoursBeforeCombobox.addItem("12");
		hoursBeforeCombobox.addItem("13");
		hoursBeforeCombobox.addItem("14");
		hoursBeforeCombobox.addItem("15");
		hoursBeforeCombobox.addItem("16");
		hoursBeforeCombobox.addItem("17");
		hoursBeforeCombobox.addItem("18");
		hoursBeforeCombobox.addItem("19");
		hoursBeforeCombobox.addItem("20");
		hoursBeforeCombobox.addItem("21");
		hoursBeforeCombobox.addItem("22");
		hoursBeforeCombobox.addItem("23");
		hoursBeforeCombobox.setEnabled(false);
		absolutePanel.add(hoursBeforeCombobox, 104, 408);
		hoursBeforeCombobox.setSize("53px", "18px");
		
		minutesBeforeCombobox = new ListBox();
		minutesBeforeCombobox.addItem("0");
		minutesBeforeCombobox.addItem("1");
		minutesBeforeCombobox.addItem("2");
		minutesBeforeCombobox.addItem("3");
		minutesBeforeCombobox.addItem("4");
		minutesBeforeCombobox.addItem("5");
		minutesBeforeCombobox.addItem("6");
		minutesBeforeCombobox.addItem("7");
		minutesBeforeCombobox.addItem("8");
		minutesBeforeCombobox.addItem("9");
		minutesBeforeCombobox.addItem("10");
		minutesBeforeCombobox.addItem("11");
		minutesBeforeCombobox.addItem("12");
		minutesBeforeCombobox.addItem("13");
		minutesBeforeCombobox.addItem("14");
		minutesBeforeCombobox.addItem("15");
		minutesBeforeCombobox.addItem("16");
		minutesBeforeCombobox.addItem("17");
		minutesBeforeCombobox.addItem("18");
		minutesBeforeCombobox.addItem("19");
		minutesBeforeCombobox.addItem("20");
		minutesBeforeCombobox.addItem("21");
		minutesBeforeCombobox.addItem("22");
		minutesBeforeCombobox.addItem("23");
		minutesBeforeCombobox.addItem("24");
		minutesBeforeCombobox.addItem("25");
		minutesBeforeCombobox.addItem("26");
		minutesBeforeCombobox.addItem("27");
		minutesBeforeCombobox.addItem("28");
		minutesBeforeCombobox.addItem("29");
		minutesBeforeCombobox.addItem("30");
		minutesBeforeCombobox.addItem("31");
		minutesBeforeCombobox.addItem("32");
		minutesBeforeCombobox.addItem("33");
		minutesBeforeCombobox.addItem("34");
		minutesBeforeCombobox.addItem("35");
		minutesBeforeCombobox.addItem("36");
		minutesBeforeCombobox.addItem("37");
		minutesBeforeCombobox.addItem("38");
		minutesBeforeCombobox.addItem("39");
		minutesBeforeCombobox.addItem("40");
		minutesBeforeCombobox.addItem("41");
		minutesBeforeCombobox.addItem("42");
		minutesBeforeCombobox.addItem("43");
		minutesBeforeCombobox.addItem("44");
		minutesBeforeCombobox.addItem("45");
		minutesBeforeCombobox.addItem("46");
		minutesBeforeCombobox.addItem("47");
		minutesBeforeCombobox.addItem("48");
		minutesBeforeCombobox.addItem("49");
		minutesBeforeCombobox.addItem("50");
		minutesBeforeCombobox.addItem("51");
		minutesBeforeCombobox.addItem("52");
		minutesBeforeCombobox.addItem("53");
		minutesBeforeCombobox.addItem("54");
		minutesBeforeCombobox.addItem("55");
		minutesBeforeCombobox.addItem("56");
		minutesBeforeCombobox.addItem("57");
		minutesBeforeCombobox.addItem("58");
		minutesBeforeCombobox.addItem("59");
		minutesBeforeCombobox.setEnabled(false);
		absolutePanel.add(minutesBeforeCombobox, 232, 408);
		minutesBeforeCombobox.setSize("50px", "18px");
		
		label_2 = new Label("minutes before the Event begins.");
		absolutePanel.add(label_2, 288, 408);
		label_2.setSize("209px", "18px");
		
		specifyAbsoluteCheckbox =  new RadioButton("time", "Specify Absolute Date and Time:");
		specifyAbsoluteCheckbox.addValueChangeHandler(new ValueChangeHandler<Boolean>() {
			public void onValueChange(ValueChangeEvent<Boolean> event) {
				if (specifyAbsoluteCheckbox.getValue()) {
					daysBeforeCombobox.setEnabled(false);
					hoursBeforeCombobox.setEnabled(false);
					minutesBeforeCombobox.setEnabled(false);
					
					sendDateAnchor.setEnabled(true);
					sendTimeAMPMCombobox.setEnabled(true);
					sendTimeHourCombobox.setEnabled(true);
					sendTimeMinuteCombobox.setEnabled(true);
				}
			}
		});
		absolutePanel.add(specifyAbsoluteCheckbox, 10, 454);
		specifyAbsoluteCheckbox.setSize("251px", "19px");
		
		specifyAbsoluteCheckbox.setValue(true);
	}
}
